<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">X</button>
			<h3 id="myModalLabel">${empty entity?'新增':'修改' }轮播图信息</h3>
		</div>
		<div class="modal-body">
			<form class="form-horizontal" method="post" id="sysUserForm" name="customerForm"
				action="customer/save${empty entity?'Insert':'Update' }.htm"
				role="form">
				<div class="form-group">
					<label class="col-sm-2 control-label">标题<font color="red">&nbsp;*</font></label>
					<div class="col-sm-10">
						<input type="hidden" value="${entity.customerId }" name="customerId" /> 
						<input type="text" class="form-control required" id="customer_phoneNum" name="phoneNum"
							value="${entity.phoneNum }">
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-sm-2 control-label">状态<font color="red">&nbsp;*</font></label>
					<div class="col-sm-10">
						<label class="checkbox-inline"> <input type="radio"
							name="state" value="1" ${entity.state=='1'?'checked':'' }>
							正常
						</label> <label class="checkbox-inline"> <input type="radio"
							name="state" value="2" ${entity.state=='0'?'checked':'' }>
							锁定
						</label><label class="checkbox-inline"> <input type="radio"
							name="state" value="3" ${entity.state=='0'?'checked':'' }>
							冻结
						</label>
					</div>
				</div>
			
				<div class="form-group">
					<label class="col-sm-2 control-label">开始时间<font color="red">&nbsp;*</font></label>
					<div class="col-sm-10">
						<input type="text" id="customer_createTime" class="form-control"
							onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'1950-01-01',maxDate:'#F{$dp.$D(\'banner_endTime\')}'})"
							value="${entity.createTime }" name="createTime" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">结束时间<font color="red">&nbsp;*</font></label>
					<div class="col-sm-10">
						<input type="text" id="customer_modifyTime" class="form-control"
							onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'banner_startTime\')}',maxDate:'2050-12-31'})"
							value="${entity.modifyTime }" name="modifyTime" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">图片上传<c:if test="${entity eq null }"><font color="red">&nbsp;*</font></c:if>
					</label>
					
					<div class="col-sm-10">
						<div class="input-group">
							<input type="file" class="form-control" id="customerFile"
								name="ustomerFile"> <span class="input-group-btn">
								<button class="btn btn-success" type="button" id="uploadcustomer">上传图片</button>
							</span>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">图片</label>
					<div class="col-sm-10">
						<div class="col-sm-6">
							<img src="${entity.image }" alt="暂无图片，点击上传！" class="img-rounded"
								style="max-width: 100%; max-height: 300px;" id="customerFile_img">
						</div>
					</div>
				</div>
				<span id="tip" style="color: red;font-size: 14px;margin-left:20px; "></span>
			</form>
		</div>
		<div class="modal-footer">
			<button class="btn btn-default" data-dismiss="modal"
				aria-hidden="true">取消</button>
			<button class="btn btn-primary" data-dismiss="modal">保存</button>
		</div>
	</div>
</div>
<script type="text/javascript"
	src="resources/js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>
<script type="text/javascript">
function check_fun(){
	$("#tip").html("");
	var b = true;
	var createTime = $("#customer_createTime").val();
	var modifyTime = $("#customer_modifyTime").val();
	var state = $('input[name="state"]:checked').val();
	var url = $("#customer_url").val();
	var title = $("#customer_title").val();
	if('${entity}' == ''){
		var file = document.customerForm.customerFile.value;
		var filepath = $("#customerFile_input").val();
		if(file == "" || filepath == null || filepath == ''){
			$("#tip").html("请上传图片");
			b = false;
		}
		
	}
	if(modifyTime == null || modifyTime.trim() == ''){
		$("#tip").html("请输入结束时间");
		b = false;
	}
	if(createTime == null || createTime.trim() == ''){
		$("#tip").html("请输入开始时间");
		b = false;
	}
	
	if(state == undefined){
		$("#tip").html("请选择状态");
		b = false;
	}
	if(url == null || url.trim() == ''){
		$("#tip").html("请输入链接");
		b = false;
	}
	if(title == null || title.trim() == ''){
		$("#tip").html("请输入标题");
		b = false;
	}
	return b;
}
	$(function() {
		$('#uploadcustomer').click(function() {
			var file = document.customerForm.customerFile.value;
			if(file == ""){
				$("#tip").html("请选择图片");
				return false;
			}
			$.ajaxFileUpload({
				type : "post",
				dataType : "json",
				fileElementId : 'customerFile',
				url : "upload/customer.htm",
				data : {
					"id" : "${entity.customerId }"
				},
				error : function(data) {
					alert("错误！");
				},
				success : function(data) {
					if (data.result = 'success') {
						console.info(data);
						alert("上传图片成功！");
						$('#customerFile_input').val(data.imgUrl);
						$('#customerFile_img').attr("src", data.imgUrl);
						$("#tip").html("");
					} else {
						alert(data.msg);
					}
				}
			});
		});
	});
</script>